// SvgIcon.vue

<template>
  <svg :class="svgClass" v-bind="$attrs" :style="{ color: color, fontSize: size + 'px' }">
    <use :href="iconName"></use>
  </svg>
</template>

<script setup>
  import { computed } from 'vue';
  const props = defineProps({
    name: {
      type: [String, Number],
      required: true,
    },
    color: {
      type: String,
      default: '',
    },
    size: {
      type: Number,
      default: () => 25,
    },
  });
  const iconName = computed(() => `#${props.name}`);
  const svgClass = computed(() => {
    if (props.name) return `svg-icon ${props.name}`;
    return 'svg-icon';
  });
</script>

<style scoped>
  .svg-icon {
    width: 1em;
    height: 1em;
    fill: currentColor;
    vertical-align: middle;
  }
</style>
